package cn.wen233.iocdemo.domain.model;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * dht11模块数据
 *
 * @author wenei
 * @date 2021-06-23 11:10
 */
public class DHT11 {

    private static Pattern pattern = Pattern.compile("[-]?[\\d]{1,3}.[\\d]{1,6}");

    public DHT11() {
    }

    public DHT11(String mqttString) {
        Matcher matcher = pattern.matcher(mqttString);
        matcher.find();
        temperature = new Double(matcher.group());
        matcher.find();
        humidity = new Double(matcher.group());
    }

    public DHT11(double temperature, double humidity) {
        this.temperature = temperature;
        this.humidity = humidity;
    }

    private double temperature;

    private double humidity;

    public double getTemperature() {
        return temperature;
    }

    public void setTemperature(double temperature) {
        this.temperature = temperature;
    }

    public double getHumidity() {
        return humidity;
    }

    public void setHumidity(double humidity) {
        this.humidity = humidity;
    }
}
